package edu.whu.demo.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.whu.demo.entity.Supplier;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SupplierMybatisPlusMapper extends BaseMapper<Supplier> {
    @Select("SELECT suppliers.* FROM suppliers,item_supplier WHERE item_supplier.item_id = #{itemId} and item_supplier.supplier_id = suppliers.id")
    List<Supplier> findSuppliersByItemId(long itemId);

    @Insert("INSERT INTO item_supplier (item_id,supplier_id) VALUES (#{itemId},#{supplierId})")
    void setItemSupplier(long itemId, long supplierId);
}
